<template>
  <div class="page">
    <van-nav-bar
      title="订单详情"
      left-text="返回"
      left-arrow
      @click-left="$router.go(-1)"
    />
    <div
      class="dd red flex f14 pt-20 pb-20 jc-sa aic"
      v-if="list.orderStatus === '00'"
    >
      <p style="color: #fff">订单已取消</p>
      <img
        src="https://file.sdyxmall.com/h5/v1/public/app/img/cancel.ff91da7.png"
        style="width: 90px"
      />
    </div>
    <van-card
      :num="item.buyNum"
      :price="item.price / 100"
      :title="item.masterName"
      :thumb="item.imgUrl"
      v-for="(item, index) in list.carts"
      :key="index"
    />

    <van-cell-group class="mt-10">
      <van-cell title="商品金额" :value="`￥${list.totalMoney}`" />
      <van-cell title="运费" value="￥0.00" />
      <van-cell title="实付">
        <span slot="right-icon" class="red">￥{{ list.totalMoney }}</span>
      </van-cell>
    </van-cell-group>

    <div class="bootom">
      <van-cell-group inset class="mt-10 mb-100">
        <van-cell
          :title="`订单编号${this.orderId}`"
          value="内容"
          label="下单时间"
        />
      </van-cell-group>
      <van-cell-group class="mt-10"
        >
        <van-cell
          title="订单状态：已取消"
          class="fixed top"
          v-if="list.orderStatus === '00'"
        >
          <button slot="right-icon" @click="zf()">重新购买</button>
        </van-cell>
        <van-cell
          title="订单状态：已支付"
          class="fixed top"
          v-if="list.orderStatus === '01'"
        >
          <button slot="right-icon" @click="zf()">再次购买</button>
        </van-cell>
        <van-cell
          title="订单状态：待支付"
          class="fixed top"
          v-if="list.orderStatus === '02'"
        >
          <button slot="right-icon" @click="ljzf()">立即支付</button>
        </van-cell>
      </van-cell-group>
    </div>
  </div>
</template>

<script>
import { detailOrder } from "@/api/index";
export default {
  data() {
    return {
      orderId: this.$route.params.orderId,
      list: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      let data = {
        orderId: this.orderId,
      };
      let res = await detailOrder(data);
      console.log(res.result);
      this.list = res.result;
    },
    zf() {
      this.$router.push({
        path: "/submit",
        query: {
          preOrderId: this.list.preOrderId,
        },
      });
    },
    ljzf() {
      this.$router.push({
        path: "/pay",
        query: {
          ewm: this.list.qrcode,
          orderId: this.list.orderId,
          allFee: this.list.totalMoney,
          time: this.list.createTime,
        },
      });
    },
  },
};
</script>

<style lang='less' scoped>
.page {
  .dd {
    background: url(https://file.sdyxmall.com/h5/v1/public/app/img/group5@2x.0b65469.png);
  }
  .top {
    bottom: 0;
  }
  .bootom {
    margin-bottom: 100px;
  }
}
</style>